﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Model;
using BLL;
using Newtonsoft.Json;
namespace LandAppraisal.Controllers
{
    public class DictionaryController : ApiController
    {
        AdminBLL bll = new AdminBLL();
        DictionaryBLL dbll = new DictionaryBLL();

        #region 获取字典表信息
        /// <summary>
        /// 获取字典表信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IEnumerable<SysDictionary> Get()
        {
            return bll.GetList<SysDictionary>();
        }
        #endregion

        #region 获取类型和编号
        /// <summary>
        /// 获取类型和编号
        /// </summary>
        /// <param name="type"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        [HttpGet]
        public string sb(string type, int i)
        {
            return JsonConvert.SerializeObject(dbll.sb(type, i));
        }
        #endregion

        #region 添加字典信息
        /// <summary>
        /// 添加字典信息
        /// </summary>
        /// <param name="value"></param>
        [HttpPost]
        public int Post([FromBody]SysDictionary dictionary)
        {
            return bll.Add<SysDictionary>(dictionary);
        }
        #endregion

        #region 修改字典信息表
        /// <summary>
        ///修改字典信息表
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        [HttpPut]
        public bool Put([FromBody] SysDictionary dictionary)
        {
            return bll.Update<SysDictionary>(dictionary);
        }
        #endregion

        #region 根据编号删除字典信息
        /// <summary>
        /// 根据编号删除字典信息
        /// </summary>
        /// <param name="id"></param>
        [HttpDelete]
        public bool Delete(int id)
        {
            return bll.DeleteById<SysDictionary>(id);
        }
        #endregion

    }
}
